package com.ken.blog.domain;

import com.ken.blog.domain.User;
import org.springframework.beans.factory.annotation.Qualifier;
import org.springframework.data.jpa.repository.JpaRepository;
import org.springframework.data.jpa.repository.Query;
import org.springframework.data.repository.NoRepositoryBean;
import org.springframework.data.repository.query.Param;
import org.springframework.stereotype.Repository;

import javax.persistence.Table;

@Table(name = "user")
@Qualifier("userRepository")
public interface UserRepository extends JpaRepository<User, Long> {
    User findOne(Long id);

    User save(User u);

    User findByName(String name);

    @Query("select u from User u where u.name=:name and u.password=:password")
    User findUserByNameAndPassword(@Param("name") String name, @Param("password") String password);
}
